package com.yangit.temp.util.img.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.yangit.temp.util.img.util.FreemarkerUtils;

/**
 * -通过freemarker 将html转换成img图片
 * @author Administrator
 *
 */
@RequestMapping(value = "/img")
@Controller
public class FreemarkerToImgController {
	
	@RequestMapping(value = "/test", method = {RequestMethod.GET})
	public void test(HttpServletResponse response) {
		System.out.println("---=-=-=");
	  try {
	      Map<String,Object> map=new HashMap<>();
	      map.put("msg","html--生成图片测试");
	      map.put("img","https://upload-images.jianshu.io/upload_images/912344-3054132dd6939004.png?imageMogr2/auto-orient/strip|imageView2/1/w/300/h/240");
	      FreemarkerUtils.turnImage("index.ftl",map,response);
	  } catch (Exception e) {
	     e.printStackTrace();
	  }
	}
	
	@RequestMapping(value = "/html", method = {RequestMethod.GET})
	public String html(HttpServletResponse response,Map<String,Object> map) {
		map.put("msg","html--生成图片测试");
	    map.put("img","https://upload-images.jianshu.io/upload_images/912344-3054132dd6939004.png?imageMogr2/auto-orient/strip|imageView2/1/w/300/h/240");
	    return "index";
	}
}

